package com.hanbang.gycatering.classify;

import com.hanbang.gangyu.R;
import com.hanbang.gycatering.homepage.BaseFragmentActivity;
import com.hanbang.gycatering.scaleview.ScaleView;
import com.hanbang.gycatering.scaleview.ScaleViewAttacher.OnViewTapListener;
import com.hanbang.gycatering.utils.SystemTools;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
 *
 */
public class BrowseImageFragment extends Fragment {

	private String imgUrl;

	public BrowseImageFragment(String imgUrl) {

		this.imgUrl = imgUrl;
	}

	@SuppressLint("InflateParams")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = LayoutInflater.from(getActivity()).inflate(
				R.layout.scale_pic_item, null);
		initView(view);
		return view;

	}

	private void initView(View view) {
		ScaleView imageView = (ScaleView) view
				.findViewById(R.id.scale_pic_item);
		((BaseFragmentActivity) getActivity()).bitmapUtils.display(imageView,
				SystemTools.getHttpFileUrl(imgUrl));
		imageView.setOnViewTapListener(new OnViewTapListener() {

			@Override
			public void onViewTap(View view, float x, float y) {
				getActivity().finish();

			}
		});
	}
}
